package mx.com.switz.peliculas.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import mx.com.switz.peliculas.service.UsuarioService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("usuario")
public class UsuarioController {
	@Autowired
	private UsuarioService usuarioServie;
	
	@RequestMapping("listar")
	@ResponseBody
	public List listarUsuarios(){
		return usuarioServie.listarUsuarios();
	}
	
	@RequestMapping("listarJSTL")
	public ModelAndView listarUsuariosJSTL(){
	return new ModelAndView("usuario/listar","usuarios",usuarioServie.listarUsuarios());	
	}
	
	@RequestMapping("goAlta")
	public String goAltaUsuario(){
		return "usuario/alta";
	}
	
	@RequestMapping(value="altaUsuario",method=RequestMethod.POST)
	public void altaUsuario(HttpServletRequest request){
	
		
		System.out.println(request.getParameter("nombre"));
	}

}
